home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PRIVATE.ZIP / _GBIOSKY.C < prev    next >
Text File  |  1992-11-21  |  3KB  |  89 lines

  1. #define        CURSES_LIBRARY  1
  2. #include <curses.h>
  3.  
  4. #ifndef        NDEBUG
  5. char *rcsid__gbiosky = "$Header: c:/curses/private/RCS/_gbiosky.c%v 2.0 1992/11/15 03:24:21 MH Rel $";
  6. #endif
  7.  
  8.  
  9.  
  10.  
  11. /*man-start*********************************************************************
  12.  
  13.   PDC_get_bios_key()   - Returns the next key available from the BIOS.
  14.  
  15.   PDCurses Description:
  16.        This is a private PDCurses routine.
  17.  
  18.        Returns the next key code struck at the keyboard. If the low 8
  19.        bits are 0, the upper bits contain the extended character
  20.        code. If bit 0-7 are non-zero, the upper bits = 0.
  21.  
  22.   PDCurses Return Value:
  23.        This function returns OK on success and ERR on error.
  24.  
  25.   PDCurses Errors:
  26.        No errors are defined for this function.
  27.  
  28.   Portability:
  29.        PDCurses        int PDC_get_bios_key( void );
  30.  
  31. **man-end**********************************************************************/
  32.  
  33. int    PDC_get_bios_key(void)
  34. {
  35. #ifdef FLEXOS
  36. unsigned ch    = 0;
  37.  
  38.        retcode = s_read(0x00, 0L, (char *) &ch, 2L, 0L);
  39.        return( (retcode < 0L) ? ERR : ch );
  40. #endif
  41. #if    defined (DOS) || defined (OS2)
  42.        int ascii,scan;
  43. #ifdef DOS
  44.        static unsigned char keyboard_function=0xFF;
  45.        unsigned char far *enhanced_keyboard;
  46.        
  47.        if (keyboard_function == 0xFF)
  48.                {
  49.                enhanced_keyboard = (unsigned char far *) 0x0496L;
  50.                regs.h.ah = 0x02;             /* get shift status for all keyboards */
  51.                int86(0x16, ®s, ®s);
  52.                scan = regs.h.al;
  53.                regs.h.ah = 0x12;             /* get shift status for enhanced keyboards */
  54.                int86(0x16, ®s, ®s);
  55.                if (scan == regs.h.al
  56.                &&  *enhanced_keyboard == 0x10)
  57.                        keyboard_function = 0x10;
  58.                else
  59.                        keyboard_function = 0x0;
  60.                }
  61.         regs.h.ah = keyboard_function;
  62.        int86(0x16, ®s, ®s);
  63.        ascii = regs.h.al;
  64.        scan = regs.h.ah;
  65. #endif
  66. #ifdef OS2
  67.        KBDKEYINFO keyInfo;
  68.        
  69.        KbdCharIn(&keyInfo, IO_WAIT, 0);        /* get a character      */
  70.        ascii = keyInfo.chChar;
  71.        scan = keyInfo.chScan;
  72. #endif
  73.        if (scan == 0x1c && ascii == 0x0a)  /* ^Enter */
  74.                return ((int) (0xfc00));
  75.        if ((scan == 0x03 && ascii == 0x00)  /* ^@ - Null */
  76.        ||  (scan == 0xe0 && ascii == 0x0d)  /* PadEnter */
  77.        ||  (scan == 0xe0 && ascii == 0x0a)) /* ^PadEnter */
  78.                return ((int) (ascii << 8));
  79.        if ((scan == 0x37 && ascii == 0x2a)  /* Star */
  80.        ||  (scan == 0x4a && ascii == 0x2d)  /* Minus */
  81.        ||  (scan == 0x4e && ascii == 0x2b)  /* Plus */
  82.        ||  (scan == 0xe0 && ascii == 0x2f)) /* Slash */
  83.                return ((int) ((ascii & 0x0f) | 0xf0) << 8);
  84.        if (ascii == 0x00 || ascii == 0xe0)
  85.                return ((int) (scan << 8));
  86.                return ((int) (ascii));
  87. #endif
  88. }
  89.